﻿// Function to prepare the options and render the control.
function renderChromeControl() {
    var options = {
        "appTitle": "Simple Universal Sheep SP Add-in"
    };

    // activate the chrome control
    var nav = new SP.UI.Controls.Navigation("SharePointChromeControl", options);
    nav.setVisible(true);
}

$(document).ready(function () {
    "use strict";

    jQuery(function () {

        //Get Host and App web URLS
        var appWebUrl = "";
        var spHostUrl = "";
        var args = window.location.search.substring(1).split("&");

        for (var i = 0; i < args.length; i++) {
            var n = args[i].split("=");
            if (n[0] == "SPHostUrl")
                spHostUrl = decodeURIComponent(n[1]);
        }

        for (var i = 0; i < args.length; i++) {
            var n = args[i].split("=");
            if (n[0] == "SPAppWebUrl")
                appWebUrl = decodeURIComponent(n[1]);
        }

        //Load Libraries
        var scriptbase = spHostUrl + "/_layouts/15/";

        // Load the js file and continue to the success handler.
        $.getScript(scriptbase + "SP.UI.Controls.js", renderChromeControl)

    });

});

